Skip to content

Swift: explicitly cast UInt32 to dispatch_flags_t #445

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

compnerd
Copy link
Member

Because dispatch_flags_t is a sized enumeration on Windows, the type
is not implicitly constructed (as in C/C++). Add the explicit
constructor call, which should be portable to all the targets.

Because `dispatch_flags_t` is a sized enumeration on Windows, the type
is not implicitly constructed (as in C/C++).  Add the explicit
constructor call, which should be portable to all the targets.
@compnerd
Copy link
Member Author

@swift-ci please test

@compnerd
Copy link
Member Author

@ktopley-apple - this fixes the Windows build and should work across all the targets

@jrose-apple
Copy link
Contributor

I'm concerned about what type is being picked for the numericCast here. This might cause problems when using a flag whose high bit is set.

@ktopley-apple
Copy link
Contributor

I'm concerned about what type is being picked for the numericCast here. This might cause problems when using a flag whose high bit is set.

dispatch_block_flags_t only has 6 defined bits, all at the low-order end, so in reality this should not be a concern. We have the practical problem that the raw value for this type is not the same on all platforms (and not even on all versions of the same platform) and there seems to be no other way to write one line of code that will convince the compiler to do the "right thing".

@ktopley-apple
Copy link
Contributor

The build failed. I saw this same failure when I last tried to fix this in a similar way. I filed a Radar on the compiler for that. It looks like the only way around this for now is to put back the Win32 conditional and use the previous version of the code for the Windows build.

@compnerd
Copy link
Member Author

Closing this since it doesn't work in favour of #446

@compnerd compnerd closed this Feb 13, 2019
@compnerd compnerd deleted the cast branch February 13, 2019 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants